﻿namespace Mozi.Live.SDP
{
    /// <summary>
    /// 频带信息
    /// </summary>
    public class SDPBandWidth
    {
        private string prefix = "AS";
        /// <summary>
        /// 前缀
        /// </summary>
        public string Prefix { get => prefix; set => prefix = value; }
        /// <summary>
        /// 单位kbps
        /// </summary>
        public int BandWidth { get; set; }
        /// <summary>
        /// 解析带宽信息
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public static SDPBandWidth Parse(string value)
        {
            string[] items = value.Split(new char[] { ':' }, System.StringSplitOptions.RemoveEmptyEntries);
            SDPBandWidth band = new SDPBandWidth();
            band.Prefix = items[0];
            band.BandWidth = int.Parse(items[1]);
            return band;
        }

        /// <summary>
        /// 转为字符串
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            return $"{Prefix}:{BandWidth}";
        }
    }

}
